// 使用map做数据次数统计
package main

import (
	"ant-learn-go/utils"
	"fmt"
	"log"
)

func main() {
	fileName := "p016_map_keyvalue_sum.txt"
	lines, err := utils.ReadFileStrings(fileName)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(lines)

	nameCount := map[string]int{}
	for _, name := range lines {
		nameCount[name]++
	}

	fmt.Println(nameCount)

	fmt.Println()
	for key, value := range nameCount {
		fmt.Printf("key=%s, value=%d\n", key, value)
	}
}
